package com.hzvtc.myproject.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Set;


@Data
@Accessors(chain = true)
public class SystemUser implements Serializable {

    private static final long serialVersionUID = 1545931180051212983L;

    private Long id; // 用户ID

    @NotNull
    @Size(min = 2, max = 20)
    private String realName; // 真实姓名

    @NotNull
    @Size(min = 5, max = 20)
    private String loginName; // 登录名称

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    transient private String password; // 密码

    private String icon; // 头像

    @Pattern(regexp = "([1][3,4,5,7,8,9][0-9]{9})|^$")
    private String cellphone; // 手机号

    @Pattern(regexp = "(\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*)|^$")
    private String email; // 邮箱

    private List<SystemRole> userRole; // 用户角色

    private List<Long> userRoleId; // 用户角色ID列表

    private Set<String> permissions; // 用户权限

    private Long leaderId; // 上级领导ID

    private SystemUser leader; // 上级领导

    @NotNull
    private Long buildingId; // 所属建筑ID

    private Building building; // 所属建筑

    private Boolean isOnLine; // 是否在线

    private List<SystemFunction> functions; // 用户所拥有的功能列表

    private LocalDateTime createTime; // 创建时间
}
